import java.io.File;

public class TestIo {
    //创建文件对象
    public static void t1()throws Exception{
        File file = new File("E:\\test.txt");
        boolean b = file.createNewFile();
        if (b){
            System.out.println("创建成功！");
        }
    }

    //创建父文件对象和子文件路径来创建对象
    public static void t2()throws Exception{
        //创建父文件对象（该目录必须为已经创建的，不会自动创建）
        File file = new File("E:\\testio");
        //创建子文件对象 new File("父路径","文件名")
        File file1 = new File(file,"t2.txt");
        boolean b = file1.createNewFile();
        if (b){
            System.out.println("创建成功！");
        }
    }

    //创建目录
    public static void t3(){
        File file = new File("E:\\text2");
        if (!file.exists()){
            boolean b = file.mkdir();
            if (b){
                System.out.println("创建成功！");
            }
        }

    }
    public static void main(String[] args)throws Exception{
        t3();
    }
}
